package queped;

import com.sun.tools.javac.util.Pair;

import java.io.Serializable;


/**
 * serializable pair
 */
public class SerializablePair<T1, T2> implements Comparable, Serializable {

    public SerializablePair() {
    }

    public SerializablePair(T1 fst, T2 second) {
        this.first = fst;
        this.second = second;
    }

    public T1 getFirst() {
        return first;
    }

    public T2 getSecond() {
        return second;
    }

    public void setFirst(T1 o) {
        first = o;
    }

    public void setSecond(T2 o) {
        second = o;
    }

    public String toString() {
        return "(" + first + "," + second + ")";
    }

    public boolean equals(Object o) {
        if (o instanceof Pair) {
            SerializablePair p = (SerializablePair) o;
            return (first == null ? p.first == null : first.equals(p.first)) && (second == null ? p.second == null : second.equals(p.second));
        } else {
            return false;
        }
    }

    public int hashCode() {
        return (((first == null) ? 0 : first.hashCode()) << 16) ^ ((second == null) ? 0 : second.hashCode());
    }

    public int compareTo(Object o) {
        SerializablePair comparee = (SerializablePair) o;
        int result = ((Comparable) getFirst()).compareTo(comparee.getFirst());
        if (result != 0) {
            return result;
        } else {
            return ((Comparable) getSecond()).compareTo(comparee.getSecond());
        }
    }
    public T1 first;
    public T2 second;

}




